<template>
  <div>
    <van-nav-bar title="通知" left-text="" left-arrow @click="backlink()" />
    <van-pull-refresh
      v-model="isLoading"
      success-text="刷新成功"
      @refresh="onRefresh"
      class="container"
    >
      <div v-for="(item, index) in message" :key="index" class="messagebox">
        <div class="avatarbox">
          <img v-lazy="item.avatar" alt="" />
        </div>
        <div class="contentbox">
          <div class="titlebox">
            <van-text-ellipsis :content="item.title" class="title" />
            <div class="tm">{{ item.time }}</div>
          </div>
          <van-text-ellipsis :content="item.content" class="content" />
        </div>
      </div>
    </van-pull-refresh>
  </div>
</template>

<script>
import { useStore } from "@/store";
export default {
  data() {
    return {
      isLoading: false,
      message: [],
    };
  },
  methods: {
    backlink() {
      this.$router.back();
    },
    onRefresh() {
      this.isLoading = false;
    },
    initMessage() {
      this.message = []
      const store = useStore();
      const tablemessage = store.getTableMessage;
      for (var i = 0; i < tablemessage.length; i++) {
        this.message.push(tablemessage[i]);
      }
    },
  },
  mounted() {
    this.initMessage();
  },
};
</script>

<style scoped>
.container {
  min-height: calc(100vh - 50px);
  background-color: #f2f3f5;
  display: flex;
  flex-direction: column;
}
.messagebox {
  width: 100%;
  height: 75px;
  background-color: #f7f8fa;
  border-bottom: 1px solid rgb(177, 177, 177);
  box-sizing: border-box;
  padding: 10px;
  display: flex;
}
.avatarbox {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
}
.avatarbox img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
}
.contentbox {
  width: calc(100vw - 100px);
  margin-left: 10px;
  display: flex;
  flex-direction: column;
}
.contentbox .titlebox {
  display: flex;
  justify-content: space-between;
  height: 30px;
}
.title {
  font-size: 16px;
  font-weight: 550;
  width: 150px;
  line-height: 30px;
}
.contentbox .tm {
  font-size: 16px;
  line-height: 30px;
  color: rgb(98, 98, 98);
}
.content {
  height: 30px;
  line-height: 30px;
  font-size: 15px;
  color: rgb(98, 98, 98);
}
</style>